/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main.Events.Entity;

import Scenery.BaseCharacter;
import Scenery.Thing.Things.Entity;
import Scenery.Thing.Things.TreeEntity;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import main.Events.Event;
import main.Main;
import main.Memory.Sound;

/**
 *
 * @author usuario
 * 
 */

public class EntityHitEvent extends Event {
    
    private BaseCharacter attacker;
    private Geometry target;

    public EntityHitEvent(BaseCharacter aThis, Geometry geometry) {
        this.attacker = aThis;
        this.target = geometry;
    }

    public BaseCharacter getAttacker() {
        return attacker;
    }

    public void setAttacker(BaseCharacter attacker) {
        this.attacker = attacker;
    }

    public Geometry getTarget() {
        return target;
    }

    public void setTarget(Geometry target) {
        this.target = target;
    }
    
     public boolean process() {
        System.out.println("!");
        if(getTarget().getName().equalsIgnoreCase("log")) {
            int hits = (Integer)getTarget().getUserData("hits");
            hits++;
            getTarget().setUserData("hits", hits);
            if(hits == 10) {
                Node tree = (Node)getTarget().getUserData("node");
                Main.getHandler().getEventHandler().callEvent(new TreeFallEvent(tree));
            }
            Sound.playSound("axe");
        }
        return true;
    }
    
}
